﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using eTMS.Controllers;
using eTMS.Controllers.SoNoSinhVienChiTietService;
using eTMS.Controllers.SoCoSinhVienChiTietService;

namespace eTMS.UserControls
{
    public partial class SinhVienPayment : eTMS.Controls.UserControlBase
    {
        public SinhVienPayment()
        {
            InitializeComponent();
        }
        private int _KieuThanhToan_ID=1;
        private int _HocKy_ID = 0;
        private int _NamHoc_ID = 0;
        public void SetHocKy_ID(int HocKy_ID)
        {
            _HocKy_ID = HocKy_ID;
        }
        public void SetKieuThanhToan_ID(int KieuThanhToan_ID)
        {
            _KieuThanhToan_ID = KieuThanhToan_ID;
        }
        public void SetNamHoc_ID(int NamHoc_ID)
        {
            _NamHoc_ID = NamHoc_ID;
        }
        private SinhVienController controller;
        public void SetDataSource(DataTable table)
        {
            khoanTienCheckList1.SetDataSource(table);
        }
        public void SetController(SinhVienController sinhVienController)
        {
            controller = sinhVienController;
        }
        public void UpdateToScreen()
        {
            khoanTienCheckList1.ClearChecked();
            foreach (SoCoSinhVienChiTietEntity soCoSinhVienChiTietEntity in controller.LsSoCoChiTietSinhVien)
            {
                khoanTienCheckList1.SetKhoanTienSoTien(soCoSinhVienChiTietEntity.KhoanTien_ID, soCoSinhVienChiTietEntity.SoTien);
            }
        }
        public void Save(bool IsDelPrev)
        {
            controller.SaveSoCoSinhVien(khoanTienCheckList1.GetData(), _HocKy_ID, _NamHoc_ID, txtGhiChu.Text,(byte) _KieuThanhToan_ID, IsDelPrev);
        }
        public void Save()
        {
            Save(true);
        }
        public void SaveSoNo()
        {
            controller.SaveSoNoSinhVien(khoanTienCheckList1.GetData(), _HocKy_ID, _NamHoc_ID, txtGhiChu.Text,false);
        }
    }
}
